<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>微信支付</title>
</head>
<body>
<div id="myQrcode"></div>
<div id="orderNo">${orderNo}</div>
<div id="payResult"></div>
<#--<div id="returnUrl" hidden>${returnUrl}</div>-->

<script src="https://cdn.bootcss.com/jquery/1.5.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script>
    jQuery('#myQrcode').qrcode({
        text:"${codeUrl}"
    });

    $(function () {
        //定时器
        var interval= setInterval(function () {
            console.log('开始查询支付状态...')
            $.ajax({
                'url': '/wxPay/queryByOrderNo',
                data: {
                    'orderNo': $('#orderNo').text()
                },
                success: function (result) {
                    console.log(result)
                    if (result.payState != null
                            && result.payState===1) {
                        $('#payResult').text("支付成功");
                        clearInterval(interval);
                    }
                },
                error: function (result) {
                    alert(result)
                }
            })
        }, 2000)
    });
</script>
</body>
</html>